package com.zyong.design.pattern.memento.case1;

/**
 * @program: zyong-design-pattern
 * @ClassName: Originator
 * @author: zyong
 * @create: 2024-05-11 23:41
 */
public class Originator {
    private String state;

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    /**
     * 保存一个状态对象Memento
     * @return
     */
    public Memento saveStateToMemento() {
        return new Memento(state);
    }

    /**
     * 通过备忘录对象，恢复状态
     * @param memento
     */
    public void getStateFromMemento(Memento memento) {
        this.state = memento.getState();
    }
}
